<script setup lang="ts">
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
import { useThemeStore } from "@/store";

// 主题初始化
const themeStore = useThemeStore();

onLaunch(() => {
  console.log("App Launch");
  // 初始化主题
  themeStore.initTheme();
  
  // 兼容web worker配置，解决FrameworkError错误
  // 在小程序环境下，确保__wxConfig.useWebWorker有默认值
  try {
    // @ts-ignore - 确保__wxConfig全局对象存在
    if (typeof window !== 'undefined' && typeof window.__wxConfig === 'undefined') {
      // @ts-ignore
      window.__wxConfig = window.__wxConfig || {};
      // @ts-ignore
      window.__wxConfig.useWebWorker = window.__wxConfig.useWebWorker || false;
    } else if (typeof wx !== 'undefined') {
      // @ts-ignore
      wx.__wxConfig = wx.__wxConfig || {};
      // @ts-ignore
      wx.__wxConfig.useWebWorker = wx.__wxConfig.useWebWorker || false;
    }
  } catch (error) {
    console.log('WebWorker compatibility patch error:', error);
  }
});

onShow(() => {
  console.log("App Show");
});

onHide(() => {
  console.log("App Hide");
});
</script>

<style lang="scss">
@import "@/static/iconfont/iconfont.css";
:root {
  --primary-color: #165dff;
  --primary-color-light: #94bfff;
  --primary-color-dark: #0e3c9b;
}

page {
  background: #f8f8f8;
  height: calc(100vh - 100rpx);
}
</style>
